Process for controlling the compression ratio of digital images

ABSTRACT

The present invention relates to a process for controlling the compression ratio of digital images. 
     This process consists of compressing a digitized image by means of a conventional process such as that known by the abbreviation JPEG. The compression ratio of the image is modified by modifying a parameter of the JPEG process, called the scale factor. According to the invention this scale factor is modified until the compression ratio obtained lies in a range of tolerance of the desired compression ratio. The process uses and approximation to the actual curve of the compression ratio as a function of the scale factor, in order to minimize the number of iterations needed to attain the desired compression ratio.

TECHNICAL FIELD

The present invention relates to a process for controlling the compression ratio of digital images.

BACKGROUND ART

The amount of digital images increases each year as new applications are found for them. However, an enormous amount of data is needed to represent a single digital image. Speaking generally, this amount of data is so large that storing and transmitting the images in their original representation is too costly and thus impractical, both from the point of view of the digital processing of the images and the economic point of view.

At present various image compression algorithms have been developed. A joint effort between the ITU (International Telecommunication Union) and the ISO (International Organisation for Standardization) has resulted in the creation of the compression standard for still images known under the name JPEG (Joint Photographic Expert Group). This algorithm is defined in “ITU-T Recommendation T.81, Digital Compression and Coding of Continuous-tone Still Images” (September 1992) and is fully illustrated in W. B. Pennebaker and J. L. Mitchell, “JPEG Still Image Compression Standard”, Van Nostrand Reinhold, New York, N.Y., USA, 1993.

When using the JPEG algorithm the compression ratio, i.e. the number of bits in the un-compressed image divided by the number of bits in the compressed image varies as a function of the complexity of the image. Thus, for example, the compression ratio of an image of a sky with few clouds is twice or three times, even more, the compression ratio of an image of a crowd in a stadium, for a substantially identical quality of restitution.

In many applications it is desirable or necessary for the user and/or the system to be able to control the compression ratio of the acquired images. In an apparatus for recording digital views, such as a photographic apparatus, it is important to be able to foresee the size of the compressed images, in order to keep the allocation of the memory of the apparatus under control.

Controlling the compression ratio is also important in networks which transmit still images or sequences of images. In these networks the time specified for transmitting a compressed image is fixed, or restricted at least, and cannot exceed a certain value, which rules out use of coding schemes which do not have control over the compression ratio.

The present invention seeks to provide an image compression process in which it is possible to choose the compression ratio with excellent precision.

SUMMARY OF THE INVENTION

In order to achieve this object, the process according to the invention is characterized in that it comprises the steps of:

compressing a digital image by means of conventional process having at least one parameter allowing the compression ratio to be modified, i.e. the ratio of the size of the un-compressed image to the size of the compressed image,

determining the compression ratio of the said conventional process,

verifying whether the compression ratio lies in a range of tolerance of a value of a specified compression ratio,

modifying said parameter if the compression ratio does not lie in the range of tolerance, and

repeating the compression of the image until the compression ratio lies in the range of tolerance.

According to a preferred embodiment, the conventional compression process is the JPEG process and the parameter which is acted upon is a scale factor serving to modify the values of the normalization matrix used by the algorithm of the JPEG process.

In the process according to the invention an initial scale factor is advantageously defined, the JPEG process is applied a first time using the initial scale factor and said process is applied again with the scale factor being modified if the actual compression ratio does not lie in the range of tolerance of the specified compression ratio.

According to an advantageous implementation of the process, the scale factor is increased when the actual compression ratio is lower than the specified compression ratio and is decreased when the actual compression ratio is greater than the specified compression ratio.

The scale factor is advantageously modified as a function of an at least partially linear model representing the compression ratio as a function of the scale factor.

Preferably the actual compression ratio is determined using said initial scale factor, the curve representing the compression ratio as a function of the scale factor is approximated by a straight line having predetermined slope m₀ and passing through a point having the initial scale factor as abscissa and the actual compression ratio obtained by applying the JPEG process with the initial scale factor as ordinate, a scale factor is determined on the basis of the straight line approximation and of the specified compression ratio, the JPEG process is applied again using this new scale factor, it is verified whether the actual compression ratio lies in the range of tolerance of the specified compression ratio, the process is terminated if the actual compression ratio lies within this range, otherwise a new scale factor is determined on the basis of a straight line approximation to the curve of the actual compression ratio as a function of the scale factor.

According to a variant embodiment, the curve representing the actual compression ratio as a function of the scale factor is advantageously approximated by straight line segments having different slopes and forming a continuous curve.

BRIEF DESCRIPTION OF THE DRAWINGS

The present invention will be better understood with reference to two non-limiting embodiments of the invention and to the accompanying drawings, in which:

FIG. 1 is a block diagram illustrating a first embodiment of the process according to the invention;

FIGS. 2a to 2 d represent the compression ratio schematically at different steps of the process of FIG. 1;

FIG. 3 is a block diagram of a second embodiment of the process according to the invention and

FIGS. 4a to 4 d represent the compression ratio at different steps of the process of FIG. 3.

PREFERRED EMBODIMENTS

The process according to the present invention is based on the JPEG algorithm and is entirely compatible therewith. The principle steps of this algorithm are defined below.

The image to be compressed is separated into blocks of 8×8 pixels. Each block is then processed separately in the identical way, in sequential manner. The steps of the process are described hereafter for one block of 8×8 pixels.

Each block is associated with a matrix of eight rows and eight columns, called the “matrix of a block” in the following.

This matrix is multiplied by the core of a linear transform known under the abbreviation 2D-DCT (2 dimension—Discrete Cosine Transform), such as is defined in the JPEG algorithm. This discrete cosine transform (DCT) converts the 8×8 pixels of the spatial domain into 8×8 coefficients in the frequency domain. The object of this transformation is to de-correlate the original data and redistribute the energy of the signal between a small number of coefficients, in the part of the low frequencies of the spectrum of the transformed data.

This transformation produces a resultant matrix containing relatively large values in a zone located towards the upper left part of the matrix and relatively small values elsewhere. The size of the zone containing the large values depends on the complexity of the image.

A normalization matrix is defined, based on a psycho-visual analysis. This matrix is used to quantize the DCT coefficients which are significant from the visual point of view with a small quantization step, while a larger quantization step is used for the rest of the coefficients.

The quantization of the DCT coefficients is the principle mechanism of compression, but also of loss of information. The system increases the level of compression by effecting entropy coding of the output of the quantizer.

The normalization matrix can be scaled by means of a factor called the scale factor, which can take any real value whatsoever greater than zero. By modifying the value of this factor it is possible to modify the compression ratio given by the JPEG method. The larger the value of the scale factor, the greater becomes the compression ratio and vice versa.

The present invention defines an efficient way of finding this scale factor while making the minimum number of iterations, with a method which does not degrade the quality of the compressed image in any way.

The proposed process is based on the demonstration by the inventors that the relationship between the scale factor and the compression ratio obtained with the JPEG compression is of quasi-linear nature.

A first embodiment of the process is described below with reference to FIGS. 1 and 2.

As already mentioned, the invention relies on the discovery that it is possible to define a relation between the scale factor and the compression ratio of the image. This relationship can be represented graphically by putting the scale factor SF on the axis of the abscissae and the compression ratio CR on the axis of the ordinates.

This first embodiment of the process is based on a strictly linear model of the compression ratio as a function of the scale factor.

In a first step 10 of the process, the compression ratio finally to be attained is fixed. This ratio is called the specified compression ratio and is abbreviated to CR_(T). It is represented by a straight line referenced 110 in FIGS. 2a to 2 d. This ratio can be fixed either for good in the control system of the compression ratio, or by the user, in particular as function of the desired image quality, the number of images to be stored in a given memory or the capacity of a transmission channel.

In this same step 10 of the process, an initial scale factor SF₁ is defined. This initial scale factor is generally defined once and for all. According to the described embodiment of the process, the initial scale factor is fixed at 1.

The JPEG algorithm is used in a second step 11 to compress an input image, the actual compression ratio CR₁ being calculated in this same step.

In step 12 of the process, the relative error between the actually obtained compression ratio CR₁ and the specified compression ratio CR_(T) is determined. If this relative error is lower than a predetermined threshold value, ±5% for example, the process is terminated and the image is stored or transmitted. This corresponds to the step 30 in FIG. 1. The difference between the specified compression ratio and the actual compression ratio is denoted ΔCR in FIG. 2d.

In the converse case, step 13 consists in defining a straight line representing the compression ratio as a function of the scale factor, this straight line modelling the actual curve of the compression ratio as a function of the scale factor. The straight line passes through a point P₁ having SF₁=1 as abscissa and CR₁ as ordinate. Its slope m₀ is defined in the control system for the compression ratio. This slope is determined as the mean slope of a set of test images.

The straight line can be written in the following manner:

CR=m ₀ ·SF+b ₀

where CR is the compression ratio, SF the scale factor and b₀ is the ordinate at the origin. This straight line has the reference 111 in FIGS. 2b, 2 c and 2 d.

The value of b₀ is given by:

b ₀ =CR ₁ −m ₀ ·SF ₁

The value of the scale factor corresponding to the compression ratio to be obtained is then determined in step 14 of the process, using the straight line defined above.

At the specified compression ratio we have:

CR _(T) =m ₀ ·SF ₂ +b ₀

from which

SF ₂=(CR _(T) −b ₀)/m ₀

This allows a new scale factor to be calculated as a function of the specified compression ratio and the actual compression ratio obtained in the first approximation.

At this stage of the process, the JPEG algorithm is used again with the scale factor SF₂. This corresponds to step 15 of FIG. 1. The actual compression ratio CR₂ is determined in this same step. This corresponds to FIG. 2c. A point P₂ having the coordinates SF₂ and CR₂ is illustrated in FIG. 2c.

In step 16, the value CR₂ obtained is compared with the value of the compression ratio CR_(T). If their difference is less than 5% the process is terminated.

In the converse case, a model straight line passing through the point P₁ with SF₁=1 as abscissa and CR₁ as ordinate and through the point P₂ having SF₂ for abscissa and CR₂ for ordinate is used. This is effected in step 17. This straight line has the reference 112 in FIG. 2d. It has a slope m₁ given by:

m ₁=(CR ₂ −CR ₁)/(SF ₂ −SF ₁)

As above, a new model is defined:

CR=m ₁ ·SF+b ₁

in which:

b ₁ =CR ₁−(m ₁ ·SF ₁)=CR ₂−(m ₁ ·SF ₂)

At the specified point of the compression ratio CR_(T), we have:

CR _(T) =m ₁ ·SF ₃ +b ₁

from which

 SF ₃=(CR _(T) −b ₁)/m ₁

The determination of this value SF₃ is effected in step 18 of the process. The JPEG algorithm is used once again to obtain the actual compression ratio CR₃. This corresponds to step 19 in FIG. 1.

This actual compression ratio CR₃ is compared in step 20 with the specified compression ratio CR_(T) and the process is terminated if these two levels have a difference less than a predetermined value.

In the converse case, the process is carried out using as a straight line approximation the straight line passing through the two last points having the calculated pairs of coordinates SF and CR.

The process is followed until the value of the actual compression ratio is within the acceptable limits for the specified compression ratio. This condition is generally realised after one to three iterations when the relative difference between the actual compression ratio and the specified compression ratio should be less than or equal to 5%. FIG. 2d further illustrates the actual curve of the compression ratio as a function of the scale factor. This curve has the reference 113.

FIGS. 3 and 4 illustrate a second embodiment of the process according to the present invention, in which the number of iterations can be reduced. This objective is attained by starting the process as described above using an initial scale factor SF₁=2 and using a better approximation to the curve representing the compression ratio as a function of the scale factor.

In the embodiment illustrated by FIGS. 1 and 2, the compression ratio as a function of the scale factor is approximated by a straight line while in the embodiment illustrated by FIGS. 3 and 4 the compression ratio is approximated by straight line segments forming a continuous curve, the slope of each segment being different in the various zones of the scale factor as a function of the actual compression ratio obtained after an iteration using SF₁ as the scale factor.

The specified compression ratio CR_(T) is introduced in a step 40.

In step 41 the actual compression ratio CR₁ is determined by applying the JPEG process with a given scale factor SF₁, equal to 2 for example.

In step 42 the value of CR₁ is compared with the specified value CR_(T). If the relative error of these two values is lower than a predetermined threshold value, 5% for example, the process is terminated and the image is stored or transmitted. This corresponds to step 50. In the converse case, the process continues with the step described below.

The approximation to the curve of the compression ratio as a function of the scale factor allows zones with different slopes to be defined. Each zone is formed by a segment having a given slope. The value of the slope for each zone is selected as a function of the value of CR₁, in accordance with the equations m=f(CR₁) of the table below, in which six zones forming six straight line segments are defined by way of example of a concrete implementation.

Zone No. Scale factor Slope 1 sfSF < 1.0 m₁ = 0.4939 CR₁ − 0.7964 2 1.0 ≦ sfSF < 1.5 m₂ = 0.3947 CR₁ − 0.3122 3 1.5 ≦ sfSF < 2.0 m₃ = 0.2894 CR₁ + 0.6244 4 2.0 ≦ sfSF ≦ 5.0 m₄ = 0.1565 CR₁ + 1.6517 5 5.0 < sfSF ≦ 10.0 m₅ = 0 CR₁ + 3.0175 6 sfSF > 10 m₆ = −0.1098 CR₁ +3.8832

The straight line which is the best adapted, i.e. that which best approximates the actual curve of the compression ratio as a function of the scale factor, is chosen as a function of the actual value of CR₁. This is effected in step 43 of the process illustrated in FIG. 3.

In step 44 the scale factor SF₂ which should correspond to the specified compression ratio CR_(T) is then estimated, using the model of the segment given by the appropriate slope m and by the point (CR₁, SF₁). The JPEG process is applied again using SF₂, which gives the compression ratio CR₂ as result.

According to step 45, if the relative error between the calculated ratio CR₂ and the specified compression ratio CR_(T) is lower than a predetermined threshold level, for example ±5%, the process is terminated. In the converse case, a supplementary iteration of the process is effected.

The number of iterations depends on the desired precision. The process is terminated when the specified compression ratio is attained, within a limit dependent on this desired precision.

One particular embodiment is described with reference to FIGS. 4a to 4 d. In this embodiment it is assumed that the scale factor being sought lies between 5 and 10.

The steps of the process are described below.

The specified compression ratio, abbreviated CR_(T) as illustrated in FIG. 4a is given. This Figure also comprises a curve 200 representing the compression ratio as a function of the scale factor.

The input image is compressed using a scale factor equal to 2. The resultant compression ratio is called CR₁ (see FIG. 4a).

If the absolute value of the relative error between CR_(T) and CR₁ is smaller that a predetermined threshold value, for example 5%, the process is terminated. In the converse case, it proceeds.

The slope of the straight line approximating the compression ratio as a function of the scale factor is then determined using the above table. In the above example, the desired scale factor corresponds to the zone No. 5 in which 5<SF<10. However, starting from the point (2, CR₁) the zone No. 4 of the table is used at first. With the value of m₄ and the point (SF₁=2, CR₁), the ordinate at the origin b₄ is implicitly defined, as with a linear model CR−m₄·SF+b₄ with the reference 201. This linear model is then used to find the scale factor which corresponds to a compression ratio CR=CR_(T). This scale factor is called SF₂ (see FIG. 4a).

In the illustrated case, SF₂>5. The linear model 201 is then used, CR=m₄·SF+b₄ to find the compression ratio CR which corresponds to a scale factor SF=5. This step determines the point (5, CR_(v))—(see FIG. 4b).

The value of CR₁ is then inserted in the zone No. 5 of the table above to find the slope m₅ of the linear model for the region 5<SF<10. This model has the reference 202 in FIG. 4b. Given the value of m₅ and the point (5, CR_(v)), the value of b₅ is implicitly defined, as in the linear model CR=m₅·SF+b₅.

This model is then used to find the scale factor which corresponds to a compression ratio CR=CR_(T). This scale factor is called SF₂. The preceding value of SF₂ becomes SF₂′.

The input image is then compressed using the normalization matrix scaled by the value SF₂. CR₂ is called the resultant compression ratio (see FIG. 4c).

If the absolute value of the relative error between CR_(T) and CR₂ is smaller than a predetermined threshold value, for example 5%, the process is terminated. Otherwise it is continued.

In order to approximate more precisely to the value of CR_(T), an adjustment of the ordinate at the origin b₅ is then necessary. The slope m₅ and the point (SF₂, CR₂) implicitly define a more accurate model CR=m₅·SF+b₅′ of the characteristic of the compression ratio as a function of the scale factor of the input image. The scale factor which corresponds to a compression ratio CR=CR_(T) is determined with this new model. This scale factor is called SF₃.

Finally, using SF₃ as the scale factor for the normalization matrix, the input image is compressed. CR₃ is called the resultant compression ratio (see FIG. 4d). If the relative error between CR₃ and CR_(T) is lower than a predetermined threshold value, the process is terminated. In the converse case, the process is continues in a similar fashion to what has been described above.

Although the basic principle used in this variant is equivalent to the principle of the process explained above, the specified value CR_(T) of the compression ratio is attained more rapidly than in the preceding embodiment.

The process according to the invention allows the compression ratio to be chosen and thus to select the memory space necessary for storing an image, or the transmission time required.

This choice of the compression ratio can be effected by the user or be predefined during the design of the coding system for several values of the compression ratio, in such a way that it cannot be modified.

The present invention is not limited to the described embodiments but extends to all variants obvious to the man skilled in the art. In particular, the initial scale factor can be modified in such a way as to arrive at the desired result as rapidly as possible. Equally, the modelling of the curve of the compression ratio as a function of the scale factor can be refined. Moreover, the tolerance for the value of the compression ratio can be chosen as a function of the required precision.

More particularly, the description of the invention which has been given refers to the case in which the specified compression ratio can be chosen within a range of values corresponding to the largest number of possible applications of the system. However, if the specified compression ratio is restricted to some previously defined and constant values, the relationships of the scale factor to the compression ratio can be optimised, while remaining within the scope of the invention, so as to reduce to 2 the number of iterations which the system requires to converge on the specified compression ratio. 

What is claimed is:
 1. A process for controlling the compression ratio of digital images, comprising the steps of: a) compressing a digital image by means of a conventional process which has at least one parameter serving to modify the compression ratio, b) calculating the compression ratio of the said conventional process, c) verifying whether the calculated compression ratio lies in a range of tolerance of the value of a specified compression ratio, d) modifying the said parameter if the calculated compression ratio does not lie in the range of tolerance, e) again compressing the image by means of the said process, using the modified parameter, f) again verifying whether the calculated compression ratio lies in the range of tolerance of the specified compression ratio, and g) repeating the steps d) to f) until the calculated compression ratio lies in the range of tolerance, wherein: the said compression process is the JPEG process, the said parameter is a scale factor serving to modify the values of the normalization matrix used by the algorithm of the JPEG process, the step a) is effected using an initial scale factor, and the modification of the scale factor at step d) is effected on the basis of an approximation of the curve representing the compression ratio as a function of the scale factor, said approximation being effected by a single straight line.
 2. The process according to claim 1, wherein the scale factor is: a) increased when the calculated compression ratio is lower than the specified compression ratio, and b) reduced when the calculated compression ratio is higher than the specified compression ratio.
 3. A process for controlling the compression ratio of digital images, comprising the steps of: a) compressing a digital image by means of a conventional process which has at least one parameter serving to modify the compression ratio, b) calculating the compression ratio of the said conventional process, c) verifying whether the calculated compression ratio lies in a range of tolerance of the value of a specified compression ratio, d) modifying the said parameter if the calculated compression ratio does not lie in the range of tolerance, e) again compressing the image by means of the said process, using the modified parameter, f) again verifying whether the calculated compression ratio lies in the range of tolerance of the specified compression ratio, and g) repeating the steps d) to f) until the calculated compression ratio lies in the range of tolerance, wherein: the said compression process is the JPEG process, the said parameter is a scale factor serving to modify the values of the normalization matrix used by the algorithm of the JPEG process, the step a) is effected using an initial scale factor, and the modification of the scale factor at step d) is effected on the basis of an approximation of the curve representing the compression ratio as a function of the scale factor, said approximation being effected by straight line segments having different slopes and forming a continuous curve.
 4. The process according to claim 3, wherein the straight line segments forming the continuous curve are defined for predetermined scale factor zones and wherein a predetermined slope for each straight line segment is defined in each of said predetermined scale factor zones.
 5. The process according to claim 3, wherein the slope of each straight line segment is a function of the compression ratio calculated on the basis of said initial scale factor.
 6. The process according to claim 3, wherein the scale factor is: a) increased when the calculated compression ratio is lower than the specified compression ratio, and b) reduced when the calculated compression ratio is higher than the specified compression ratio.
 7. A process for controlling the compression ratio of digital images comprising the steps of: a) compressing a digital image by means of the JPEG process using a selected scale factor and calculating the corresponding compression ratio, b) verifying whether the calculated compression ratio lies in a range of tolerance of the value of a specified compression ratio, c) terminating the process if the calculated compression ratio lies in the said range of tolerance, d) if the calculated compression ratio does not lie in the said range, approximating the curve representing the compression ratio as a function of the scale factor by a straight line having a given slope and passing through a first point having as coordinates the selected scale factor and corresponding calculated compression ratio of step a), e) determining a new scale factor on the basis of the said straight line and the specified compression ratio, f) repeating steps a) to e) using the new scale factor determined at step e) as the selected scale factor until the corresponding calculated compression ratio lies in the said range of tolerance, wherein, during an initial iteration of the process where steps a) to e) are performed for the first time, the selected scale factor is selected to be a given initial scale factor and the said straight line is defined at step d) as a straight line having a predetermined slope and passing through said first point having as coordinates the said initial scale factor and corresponding calculated compression ratio, wherein, during subsequent iterations of the process where steps a) to e) are repeated, the said straight line is defined at step d) as a straight line passing through said first point and through a second point having as coordinates the selected scale factor and corresponding calculated compression ratio of step a) of a preceding iteration.
 8. The process according to claim 7, wherein said predetermined slope is determined as the mean slope of a set of test images.
 9. A process for controlling the compression ratio of digital images comprising the steps of: a) compressing a digital image by means of the JPEG process using a selected scale factor and calculating the corresponding compression ratio, b) verifying whether the calculated compression ratio lies in a range of tolerance of the value of a specified compression ratio, c) terminating the process if the calculated compression ratio lies in the said range of tolerance, d) if the calculated compression ratio does not lie in the said range, approximating the curve representing the compression ratio as a function of the scale factor by a continuous curve formed of straight line segments of different slopes, a first of said straight line segments forming the continuous curve having a predetermined slope (m₁ to m₆) and passing through a first point having as coordinates the selected scale factor and corresponding calculated compression ratio of step a), e) determining a new scale factor on the basis of the said continuous curve and the specified compression ratio, f) repeating steps a) to e) using the new scale factor determined at step e) as the selected scale factor until the corresponding calculated compression ratio lies in the said range of tolerance, wherein, during an initial iteration of the process where steps a) to e) are performed for the first time, the selected scale factor is selected to be a given initial scale factor.
 10. The process according to claim 9, wherein the straight line segments forming the continuous curve are defined for predetermined scale factor zones and wherein a predetermined slope for each straight line segment is defined in each of said predetermined scale factor zones.
 11. The process according to claim 9, wherein the slope of each straight line segment is a function of the compression ratio calculated on the basis of said initial scale factor. 